<%@page import="org.omg.PortableServer.AdapterActivator"%>
<%@page import="servlets.AdminServlet"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.ArrayList"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>

<!-- Icons for Web App<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" sizes="114x114" href="images/nav/index@2x.png">
<link rel="apple-touch-startup-image" href="images/splash/splash-screen.png" media="screen and (max-device-width: 320px)" />
<link rel="apple-touch-startup-image" media="(max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2)" href="images/splash/splash-screen@2x.png" />
-->
<title>Frontera Pesos Login</title>
<link href="styles/style.css" rel="stylesheet" type="text/css">
<link href="styles/type.css" rel="stylesheet" type="text/css">
<link href="styles/buttons.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" media="only screen and (-webkit-min-device-pixel-ratio: 2)"	type="text/css" href="styles/highdpi.css" />

<!-- Load the Latest JQuery Version and Latest Validation Plugin -->
<script src="http://code.jquery.com/jquery-latest.js"></script>


<!-- utility js -->
<script type="text/javascript" src="scripts/fronteraWebUtility.js"></script>

</head>
<body >
<%
String serverName =  request.getRemoteHost();
System.out.println("server = " + serverName);
Cookie[] cookies = request.getCookies();
String _loginID = "";

 boolean foundCookie = false;
 if(cookies != null)
 {
 for(int i = 0; i < cookies.length; i++) { 
     Cookie cookie1 = cookies[i];
     System.out.println("cookie = " + cookie1.getValue());
     System.out.println("cookie name = " + cookie1.getName());
     
     if (cookie1.getName().equals("frontera")) {
     	System.out.println("frontera cookie found = " + cookie1.getValue());
         foundCookie = true;
         break;
     }
 }
 }
%>

<form name="cookieForm" id="cookieForm" action="Admin" method="get" style="display:none">
<input type="hidden" name="adminRequestType" id="adminRequestType" value="cookie"  />
<input type="hidden" name="phone" id="phone"    />
<input type="hidden" name="fronteraFolder" id="fronteraFolder"   />
			 
</form>
<script type="text/javascript">
var autoLogin = false;
//alert("here before");

//var g = getFronteraPath();
//alert("get path g " + g);
function autoLoginUserIn()
	{
	var i = getCookie('frontera');
	my_form=document.getElementById("cookieForm");
	document.forms["cookieForm"]["phone"].value = i;
	document.forms["cookieForm"]["fronteraFolder"].value = getFronteraPath();
	
	if(autoLogin)//send use to home page
		{
			my_form.method='POST';//POST
			my_form.action='Admin';
			
		}
	else//send user to login page
		{
			my_form.method='POST';//POST
			my_form.action='login.jsp';
			
		}
	
	my_form.submit();
	
	}
	var cookieExist = getCookie('frontera');
	if(cookieExist != undefined)
		{
			
			autoLogin = true;
			
		}
	autoLoginUserIn();	
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
</script>
	<div class="landing-page">
		<p class="center-text landing-logo shadow">
			<img class="replace-2x" width="300" src="assets/FroLogoRetina.png"
				alt="img"> <br /> Frontera Pesos Rewards Program!
		</p>

		<div class="login-box">
			<div class="center">
				<p>Please wait...</p>
				<img src="assets/img-preloader.gif" alt="img" height="50" width="50"
					class="replace-2x">
			</div>
		</div>

	</div>



</body>
</html>